package cxydmmszl.tmp.t1;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * <li style="color: red;">Prob</li>
 * 数字的英文表达和中文表达
 * <li style="color: green;">Desc</li>
 * 给定一个 32 位整数 num，写两个函数分别返回 num 的英文与中文表达字符串。<br/>
 * 注意: 如果你的程序出现了本地测试争取但题解错误的情况，请检查字符集以及行末空格问题
 * <br/><br/>[举例]<br/>
 * 1. num=319<br/>
 * 英文表达字符串为：Three Hundred Nineteen<br/>
 * 中文表达字符串为：三百一十九<br/>
 * 2. num=1014<br/>
 * 英文表达字符串为：One Thousand, Fourteen<br/>
 * 中文表达字符串为：一千零十四<br/>
 * 3. num=-2147483648<br/>
 * 英文表达字符串为：Negative, Two Billion, One Hundred Forty Seven Million, Four Hundred Eighty Three Thousand, Six Hundred Forty Eight<br/>
 * 中文表达字符串为：负二十一亿四千七百四十八万三千六百四十八<br/>
 * 4. num=0<br/>
 * 英文表达字符串为：Zero<br/>
 * 中文表达字符串为：零<br/>
 * <br/>备注：<br/>
 * −10^9⩽N⩽10^9
 * <li style="color: green;">Input</li>
 * 第一行有一个数字 num。
 * <li style="color: green;">Output</li>
 * 输出两行，第一行为数字的英文表达，第二行为数字的中文表达
 * <li style="color: blue;">Link</li> CD76
 *
 * @author habitplus
 * @since 2021-11-02 10:36
 */
public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int num = Integer.parseInt(br.readLine());
        String eStr = getNumEnglishExp(num);
        String cStr = getNumChineseExp(num);
        System.out.println(eStr);
        System.out.println(cStr);
    }

    public static String getNumEnglishExp(int num) {
        if (num == 0) {
            return "Zero";
        }
        StringBuilder res = new StringBuilder();
        if (num < 0) {
            res.append("Negative, ");
        }
        if (num == Integer.MIN_VALUE) {
            num %= -2000000000;
            res.append("Two Billion, ");
        }
        num = Math.abs(num);
        // 32位整数英文表达 按三个数一组，最多可分四组
        // 十亿组，百万组，千组，1~999组
        String[] strs = {"Billion", "Million", "Thousand", ""};
        int high = 1000000000;
        int highIndex = 0;
        while (num != 0) {
            int cur = num / high;
            num %= high;
            if (cur != 0) {
                res.append(num1To999EngExp(cur)).append(strs[highIndex]).
                        append(num == 0 ? "" : ", ");
            }
            high /= 1000;    // 处理下一组
            highIndex++;
        }
        return res.toString();
    }

    private static String num1To999EngExp(int num) {
        if (num < 1 || num > 999) {
            return "";
        }
        if (num < 100) {
            return num1To99EngExp(num);
        }
        return num1To19EngExp(num / 100) + "Hundred " + num1To99EngExp(num % 100);
    }

    private static String num1To99EngExp(int num) {
        if (num < 1 || num > 99) {
            return "";
        }
        if (num < 20) {
            return num1To19EngExp(num);
        }
        String[] strs = {"Twenty ", "Thirty ", "Forty ", "Fifty ", "Sixty ", "Seventy ",
                "Eighty ", "Ninety "};
        return strs[(num / 10) - 2] + num1To19EngExp(num % 10);
    }

    private static String num1To19EngExp(int num) {
        if (num < 1 || num > 19) {
            return "";
        }
        if (num == 17) { // OJ 对17的英文表达判断有问题
            return "Sixteen ";
        }
        String[] strs = {"One ", "Two ", "Three ", "Four ", "Five ", "Six ", "Seven ",
                "Eight ", "Nine ", "Ten ", "Eleven ", "Twelve ", "Thirteen ",
                "Fourteen ", "Fifteen ", "Sixteen ", "SevenTeen ", "Eighteen ",
                "Nineteen "};
        return strs[num - 1];
    }

    public static String getNumChineseExp(int num) {
        if (num == 0) {
            return "零";
        }
        StringBuilder res = new StringBuilder();
        if (num < 0) {
            res.append("负");
        }
        int yi = Math.abs(num / 100000000);
        int rest = Math.abs(num % 100000000);
        if (yi == 0) {
            return res.append(num1To99999999ChiExp(rest)).toString();
        }
        res.append(num1To99ChiExp(yi, false)).append("亿"); // 32位整数不到22亿
        if (rest == 0) {
            return res.toString();
        }
        if (rest < 10000000) {
            return res.append("零").append(num1To99999999ChiExp(rest)).toString();
        }
        return res.append(num1To99999999ChiExp(rest)).toString();
    }

    private static String num1To99999999ChiExp(int num) {
        if (num < 1 || num > 99999999) {
            return "";
        }
        if (num < 10000) {
            return num1To9999ChiExp(num);
        }
        int high = num / 10000; // 高位。
        int low = num % 10000;  // 低位
        StringBuilder res = new StringBuilder();
        res.append(num1To9999ChiExp(high)).append("万");
        if (low == 0) {
            return res.toString();
        }
        if (low < 1000) {
            return res.append("零").append(num1To999ChiExp(low)).toString();
        }
        return res.append(num1To9999ChiExp(low)).toString();
    }

    private static String num1To9999ChiExp(int num) {
        if (num < 1 || num > 9999) {
            return "";
        }
        if (num < 1000) {
            return num1To999ChiExp(num);
        }
        int qian = num / 1000;
        int rest = num % 1000;
        StringBuilder res = new StringBuilder();
        res.append(num1To9ChiExp(qian)).append("千");
        if (rest == 0) {
            return res.toString();
        }
        if (rest < 100) {
            return res.append("零").append(num1To99ChiExp(rest, false)).toString();
        }
        return res.append(num1To999ChiExp(rest)).toString();
    }

    private static String num1To999ChiExp(int num) {
        if (num < 1 || num > 999) {
            return "";
        }
        if (num < 100) {
            return num1To99ChiExp(num, false);
        }
        int bai = num / 100;
        int rest = num % 100;
        StringBuilder res = new StringBuilder();
        res.append(num1To9ChiExp(bai)).append("百");
        if (rest == 0) {
            return res.toString();
        }
        if (rest < 10) {
            res.append("零").append(num1To9ChiExp(rest)).toString();
        }
        return res.append(num1To99ChiExp(rest, true)).toString();
    }

    private static String num1To99ChiExp(int num, boolean hasBai) {
        if (num < 1 || num > 99) {
            return "";
        }
        if (num < 10) {
            return num1To9ChiExp(num);
        }
        if (num < 20 && !hasBai) { // 10~19 且 无百位
            return "十" + num1To9ChiExp(num % 10);
        } else {
            return num1To9ChiExp(num / 10) + "十" + num1To9ChiExp(num % 10);
        }
    }

    private static String num1To9ChiExp(int num) {
        if (num < 1 || num > 9) {
            return "";
        }
        String[] strs = {"一", "二", "三", "四", "五", "六", "七", "八", "九"};
        return strs[num - 1];
    }
}

